import request from '@/utils/request'

const PREFIX = '/global'

/**
 * 查询城市等级列表
 * @param {Object}data
 * @returns {AxiosPromise}
 */
export function getCityGrade(data) {
  return request({
    url: `${PREFIX}/citygrade/search`,
    method: 'post',
    data
  })
}

/**
 * 更新城市等级状态
 * @param data
 * @returns {AxiosPromise}
 */
export function updateState(data) {
  return request({
    url: `${PREFIX}/citygrade/updateIsActive`,
    method: 'post',
    data
  })
}

/**
 * 删除城市等级
 * @param id
 * @returns {AxiosPromise}
 */
export function removeRow(id) {
  return request({
    url: `${PREFIX}/citygrade/${id}`,
    method: 'delete',
    params: {}
  })
}

/**
 * 保存城市等级
 * @param data
 * @returns {AxiosPromise}
 */
export function saveCityGrade(data) {
  return request({
    url: `${PREFIX}/citygrade`,
    method: 'post',
    data
  })
}

/**
 * 获取设置过城市等级的城市列表
 * @param {Number}city 地域id
 * @param {Number}grade 城市等级id
 * @returns {AxiosPromise}
 */
export function getCitiesIsGrade(city, grade) {
  return request({
    url: `${PREFIX}/district/searchChildListById/${city}/${grade}`,
    method: 'post',
    data: {}
  })
}

/**
 * 城市等级详情
 * @param {Number}id
 * @returns {AxiosPromise}
 */
export function getCityGradeDetail(id) {
  return request({
    url: `${PREFIX}/citygrade/${id}`,
    method: 'get'
  })
}

/**
 * 修改城市等级
 * @param {Object}data
 * @param {Number}id
 * @returns {AxiosPromise}
 */
export function updateCityGrade(data, id) {
  return request({
    url: `${PREFIX}/citygrade/${id}`,
    method: 'put',
    data
  })
}

/**
 * 城市列表更新城市等级
 * @param {Number} city
 * @param {Number} grade
 * @returns {AxiosPromise}
 */
export function setCityGrade(city, grade) {
  return request({
    url: `${PREFIX}/district/updateCitygrade/${city}/${grade}`,
    method: 'post',
    data: {}
  })
}

/**
 * 更新旅游城市
 * @param {Array} data
 * @param {Number}saveType
 * @param {String} method
 * @returns {AxiosPromise}
 */
export function setTourCity(data, saveType, method) {
  return request({
    url: `${PREFIX}/districtseason/${saveType}`,
    method: method,
    data
  })
}

/**
 * 取消旅游城市
 * @param path
 * @returns {AxiosPromise}
 */
export function cancelTourCity(data) {
  return request({
    url: `${PREFIX}/districtseason/cancelseason`,
    method: 'post',
    data
  })
}

/**
 * 获取旅游城市详情
 * @param {Number}id
 * @returns {AxiosPromise}
 */
export function getTourCityDetail(id) {
  return request({
    url: `${PREFIX}/districtseason/${id}`,
    method: 'get'
  })
}
